#pragma once
#include"fit_modul.h";
#include <gsl/gsl_blas.h>
#include <gsl\gsl_vector.h>
#include <gsl\gsl_multifit_nlin.h>


const double errabs=1e-4;
const double errrel=0.05;

class fitting
{
public:
	fitting(fit_modul modul);
	~fitting(void);
	 
	//struct data {
 //      size_t n;
 //      double * y;
 //      double * sigma;
	//   fitting &ref;
 //    };

	struct parameter{
		double value;
		bool fit;
		std::string name;
	};
	fit_modul *modul;

	int fit();
	void loadData(std::string filename);
	void setModul(fit_modul *modul);
	int get_paramcount();
	std::vector<parameter> get_param();
	void set_param_value(int i, double value);
	void set_param_fit(int i,bool fit);

	std::string filename;

	
private:
	
	
	
	std::vector<double> xdata;			//experimental independent data
	std::vector<double> ydata;			//experimental dependent data
	std::vector<parameter> param;		//parameter of the model
	int paramcount;						//number of parameters to fit
	//int func_f(const gsl_vector* x,void *data, gsl_vector * f);
	//int df(const gsl_vector * x, void *data, gsl_matrix * J);
	//int fdf (const gsl_vector * x, void *data,gsl_vector * f, gsl_matrix * J);
	void getPrameter();
	void print_state (size_t iter, gsl_multifit_fdfsolver * s,std::fstream &logfile);	//prints the state of the fit
};

